import * as types from '../mutation-types'

const state = {
    markData: null,
    successData: [],
    localPage: 1,
    tools: '',
    toolsCount: 0,
    markSelected: {},
    currentImage: 0,
    imageList: [],
    testCache: null,
    editFormItem: null,
    editTemplate: null,
    standardUpdateTotal: 0,
    navHidden: '',
}

const getters = {
    markData: state => state.markData,
    successData: state => state.successData,
    localPage: state => state.localPage,
    tools: state => state.tools,
    toolsCount: state => state.toolsCount,
    markSelected: state => state.markSelected,
    currentImage: state => state.currentImage,
    imageList: state => state.imageList,
    testCache: state => state.testCache,
    editFormItem: state => state.editFormItem,
    editTemplate: state => state.editTemplate,
    navHidden: state => state.navHidden,
}

const mutations = {
    [types.SETMARKDATA]: (state, value) => {
        state.markData = value
    },
    [types.SETSUCCESSDATA]: (state, value) => {
        state.successData = value
    },
    [types.SETLOCALPAGE]: (state, value) => {
        state.localPage = value
    },
    [types.OPENTOOLS]: (state, value) => {
        state.tools = value;
        state.toolsCount++;
    },
    [types.MARKSELECTED]: (state, value) => {
        state.markSelected = value;
    },
    [types.CURRENTIMAGE]: (state, value) => {
        state.currentImage = value;
    },
    [types.IMAGELIST]: (state, value) => {
        state.imageList = value;
    },
    [types.TESTCACHE]: (state, value) => {
        state.testCache = value;
    },
    [types.EDITFORMITEM]: (state, value) => {
        state.editFormItem = value;
    },
    [types.EDITTEMPLATE]: (state, value) => {
        state.editTemplate = value;
    },
    [types.STANDARDUPDATETOTAL]: (state, value) => {
        state.standardUpdateTotal = value;
    },
    [types.SETNAVHIDDEN]: (state, value) => {
        state.navHidden = value;
    },
}

const actions = {
    setMarkData({ commit }, value) {
        commit(types.SETMARKDATA, value);
    },
    setSuccessData({ commit }, value) {
        commit(types.SETSUCCESSDATA, value);
    },
    setLocalPage({ commit }, value) {
        commit(types.SETLOCALPAGE, value);
    },
    setOpenTools({ commit }, value) {
        commit(types.OPENTOOLS, value);
    },
    setMarkSelected({ commit }, value) {
        commit(types.MARKSELECTED, value);
    },
    setCurrentImage({ commit }, value) {
        commit(types.CURRENTIMAGE, value);
    },
    setImageList({ commit }, value) {
        commit(types.IMAGELIST, value);
    },
    setTestCache({ commit }, value) {
        commit(types.TESTCACHE, value);
    },
    setEditFormItem({ commit }, value) {
        commit(types.EDITFORMITEM, value);
    },
    setEditTemplate({ commit }, value) {
        commit(types.EDITTEMPLATE, value);
    },
    setStandardUpdateTotal({ commit }, value) {
        commit(types.STANDARDUPDATETOTAL, value);
    },
    setNavHidden({ commit }, value) {
        commit(types.SETNAVHIDDEN, value);
    },
}



export default {
    state,
    getters,
    actions,
    mutations
}